using System.Data;
using Orchard.Data.Migration;
using Orchard.ContentManagement.MetaData;
using Orchard.Indexing;
using Orchard.Core.Contents.Extensions;

namespace Eneta.Profiles {
    public class Migrations : DataMigrationImpl {

        public int Create() {
			// Creating table ProfilePartRecord
			SchemaBuilder.CreateTable("ProfilePartRecord", table => table
				.ContentPartRecord()
				.Column("FirstName", DbType.String)
				.Column("LastName", DbType.String)
			);



            return 1;
        }

        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterTypeDefinition("Profile", cfg => cfg
                .WithPart("CommonPart")
                .WithPart("RoutePart")
                .WithPart("BodyPart")
                .WithPart("ProfilePart")
                .WithPart("CommentsPart")
                .WithPart("TagsPart")
                .WithPart("LocalizationPart")
                //.Creatable()
                .Indexed());

            return 2;
        }

        public int UpdateFrom2()
        {
            ContentDefinitionManager.AlterTypeDefinition("Profile", cfg => cfg.Creatable());

            return 3;
        }
    }
}